import { GameMode } from "@minecraft/server";
import { DirtShopMoudle } from "../module";
import { EffectIds } from "@sapi-game/utils/vanila-data";

export class DirtShopEndState extends DirtShopMoudle.State {
    protected override onEnter(): void {
        this.initPlayer();
        this.runner.runDelay(() => {
            this.engine.stopGame();
        }, 200);
    }

    initPlayer() {
        this.context.groupSet.forEach((p) => {
            p.player.setGameMode(GameMode.Adventure);
            p.addEffect(EffectIds.Resistance, 100, 255);
        });
        this.context.host.forEach((p) => {
            p.player.teleport(this.context.map.hostEndPos);
        });
        this.context.attacker.forEach((p) => {
            p.player.teleport(this.context.map.attackerEndPos);
        });
    }
}
